// import {message} from 'antd';
import axios from 'axios';
import {TOOL_KIT_SERVER_HOST, TOOL_KIT_SERVER_TOKEN} from '@/common/config';

export const fetchToolkit = axios.create({
    baseURL: TOOL_KIT_SERVER_HOST,
    timeout: 10000
});

fetchToolkit.interceptors.request.use(config => {
    const {headers} = config || {};
    !headers.has('Authorization') && headers.set('Authorization', TOOL_KIT_SERVER_TOKEN);
    return config;
}, error => {
    return Promise.reject(error);
});

fetchToolkit.interceptors.response.use(response => {
    return response.data;
}, error => {
    // message.error(error?.response?.data?.message || '请求失败');
    return Promise.reject(error?.response?.data);
});
